package com.cf.base.comm.tools;

import android.app.Application;


/**
 * @author yangji
 */
public class CommApplication {

    private Application application;
    private CurrentActivity mCurrentActivity;
    private VisibilityTracker mVisibilityTracker;

    public static BaseSingleton<CommApplication> singleton = new BaseSingleton<CommApplication>() {
        @Override
        protected CommApplication create() {
            return new CommApplication();
        }
    };

    static void install(Application application) {
        singleton.get().application = application;
        singleton.get().onCreate();
    }

    protected void onCreate() {
        DisplayUtils.singleton.get().init(application);
        ResourcesUtils.singleton.get().init(application);
        application.registerActivityLifecycleCallbacks(mCurrentActivity);
        application.registerActivityLifecycleCallbacks(mVisibilityTracker);
    }

    public CurrentActivity getCurrentActivity() {
        return mCurrentActivity;
    }

    public VisibilityTracker getVisibilityTracker() {
        return mVisibilityTracker;
    }
}
